package com.chinaunicom.emergency.exception;

import com.chinaunicom.emergency.serializer.OAuth2ExceptionSerializer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;

/**
 * @author liliang
 * @date 2019-12-13
 * 认证异常
 */
@JsonSerialize(using = OAuth2ExceptionSerializer.class)
public class OAuthException extends OAuth2Exception {
    private Integer status = 400;

    public OAuthException(String message, Throwable t) {
        super(message, t);
        status = ((OAuth2Exception)t).getHttpErrorCode();
    }


    public OAuthException(String message) {
        super(message);
    }
    @Override
    public int getHttpErrorCode() {
        return status;
    }

    private boolean needCode = false;

    public OAuthException(String message,boolean needCode, Throwable t) {
        super(message, t);
        status = ((OAuth2Exception)t).getHttpErrorCode();
        this.needCode = needCode;
    }


    public OAuthException(String message,boolean needCode) {
        super(message);
        this.needCode = needCode;
    }

    public boolean isNeedCode() {
        return needCode;
    }

    public void setNeedCode(boolean needCode) {
        this.needCode = needCode;
    }




}
